using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CampaignWP7.Base;
using Microsoft.Xna.Framework;
using cocos2d;

namespace CampaignWP7
{
    public class UFOFireEmitter : DynamicsEmitter
    {
        public enum FireType
        {
            UFOFIRE_BULLET = 0,
            UFOFIRE_WOLF,
        }

        public float Strength { get; set; }
        public FireType curFireType  { set; get; }

        public UFOFireEmitter()
        {
            Reset();
            Enable = false;
        }

        public override void Emit(float dt)
        {
            //if (!Enable) return;
            Counter += dt;
            if (Counter > DelayTime)
            {
                Counter = 0;

                switch (curFireType)
                {
                    case FireType.UFOFIRE_BULLET:
                        EnemyBullet bullet = new EnemyBullet();
                        bullet.position = new CCPoint(position.x, position.y);
                        bullet.PlayShootAnimation();
                        bullet.Velocity = Direction * Strength;

                        DynamicMgr.Instance().AddChild(bullet);
                        break;
                    case FireType.UFOFIRE_WOLF:
                        Wolf wolf;
                        wolf = new Wolf(1);
                        wolf.position = new CCPoint(position.x, position.y);
                        wolf.PlayWalkAnimation();
                        wolf.Velocity = new Vector2(0, 0);
                        wolf.Acceleration = DynamicsObj.Gravity * -1;
                        wolf.userData = 2.0f;
                        DynamicMgr.Instance().AddChild(wolf);
                        wolf.PlayMoveToJump(0, position);
                        break;
                }
            }
        }

        public override void Reset()
        {
            DelayTime = 1;
            Strength = 10;
            Direction = new Vector2(0, 0);
            //
            Counter = 0;

            curFireType = FireType.UFOFIRE_BULLET;
        }
    }
}
